//
//  YFStatisticsModel.h
//  SquashSpark
//
//  Created by Coollang on 2017/12/13.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Realm/Realm.h>

// 数据模型
typedef enum : NSInteger {
    kStatisticsModelWeek = 0,
    kStatisticsModelMonth,
    kStatisticsModelYear,
} kStatisticsModelType;

/* 先请求网路上的数据，网络数据请求成功就更新本地数据，失败直接本地数据 */
@interface YFStatisticsModel :RLMObject

// key: UserId + 类型 + page
@property NSString *indentation;

/** 模型数据类型 */
@property kStatisticsModelType statisticDataType;
/** 当前页 */
@property NSInteger currentPage;

/** 给柱状图用的数据:周和月为字典类型，年的为数组类型:没办法只能存字符串 */
@property NSString *dataJson;

@property NSInteger totalCaroline;
@property NSInteger totalDuration;
@property NSInteger totalSwings;
@property NSInteger avgDuration;
@property NSInteger maxSpeed;
@property NSInteger totalPage;

- (void)statisticsModelWithServerDict:(NSDictionary *)dict;

+ (YFStatisticsModel *)StatisticsModelWithPrivateType:(kStatisticsModelType)dataType page:(NSInteger)page;

// 网络数据请求
+ (void)loadWeekDataWithPage:(NSInteger)page completed:(void(^)(BOOL suceess,YFStatisticsModel *weekDataModel))completed;
+ (void)loadMonthDataWithPage:(NSInteger)page completed:(void(^)(BOOL suceess,YFStatisticsModel *monthDataModel))completed;
+ (void)loadYearDataWithPage:(NSInteger)page completed:(void(^)(BOOL suceess,YFStatisticsModel *yearDataModel))completed;

@end
RLM_ARRAY_TYPE(YFStatisticsModel)

